//
//  NSString+MD5.m
//  LogisticsProduct
//
//  Created by 孟学浩 on 2017/3/10.
//  Copyright © 2017年 com.puyiwang.logistics. All rights reserved.
//

#import "NSString+MD5.h"
#import <CommonCrypto/CommonDigest.h>

@implementation NSString (MD5)
#pragma mark - 32位 小写
+ (NSString *) md5:(NSString *)str{
    //要进行UTF8的转码
    const char* input = [str UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    CC_MD5(input, (CC_LONG)strlen(input), result);
    
    NSMutableString *digest = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for (NSInteger i = 0; i < CC_MD5_DIGEST_LENGTH; i++) {
        [digest appendFormat:@"%02x", result[i]];
    }
    
    return digest;
}

//+ (NSString *)dealUrlChinese:(NSString *)url{
//    NSCharacterSet *set = [NSCharacterSet URLQueryAllowedCharacterSet];
//    NSString *encodedString = [url stringByAddingPercentEncodingWithAllowedCharacters:set];
//    return encodedString;
//}
@end
